package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.wemedia.service.StatisticsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author: fly
 * @date: 2024-08-02 14:03
 */
@RestController
@RequestMapping("/api/v1/statistics")
@Slf4j
public class StatisticsController {
    @Autowired
    private StatisticsService statisticsService;

    /**
     * 图文数据总览
     * @param beginDate
     * @param endDate
     * @return
     */
    @GetMapping("/newsDimension")
    public ResponseResult newsDimension(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate){
        log.info("begin={},end={}",beginDate,endDate);
        return statisticsService.newsDimension(beginDate,endDate);
    }

    /**
     * 图文数据列表
     * @param beginDate
     * @param endDate
     * @param page
     * @param size
     * @return
     */
    @GetMapping("/newsPage")
    public ResponseResult newsPage(@DateTimeFormat(pattern = "yyyy-MM-dd") Date beginDate, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endDate,Integer page,Integer size){
        log.info("begin={},end={},page={},size={}",beginDate,endDate,page,size);
        return statisticsService.newsPage(beginDate,endDate,page,size);
    }
}
